﻿using System;
using JStore.Core.Entities;
using JStore.Data.Daos;
using SpeadFrm.MvcPager;

namespace JStore.Tasks
{
    /// <summary>
    ///
    /// </summary>
    public class SysMsgTask
    {
        private readonly SysMsgDao _sysMsgDao = new SysMsgDao();

        public void CreateMsg(int userId, string userName,string title, string content)
        {
            var info = new SysMsg
                           {
                               CreateDate = DateTime.Now,
                               IsDelete = false,
                               IsRead = false,
                               Title = title,
                               MsgContent = content,
                               UserId = userId,
                               UserName = userName
                           };
            _sysMsgDao.Add(info);
        }

        public PagedList<SysMsg> GetPagedList(string userName, int pageIndex, int pageSize)
        {
            return _sysMsgDao.GetPagedList(userName, pageIndex, pageSize);
        }

        public SysMsg GetById(int id)
        {
            return _sysMsgDao.GetById(id);
        }

        public void SetRead(int id)
        {
            _sysMsgDao.SetRead(id);
        }

        public int GetCount(string userName)
        {
            return _sysMsgDao.GetCount(userName);
        }
    }
}

